package com.mdlaser.sys.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mdlaser.sys.dto.ResourceDto;
import com.mdlaser.sys.entity.Resource;
import com.mdlaser.sys.mapper.ResourceMapper;
import com.mdlaser.sys.service.IResourceService;
import com.mdlaser.sys.vo.ResourceVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author mdlaser
 * @since 2024-04-05
 */
@Service
public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource> implements IResourceService {

    @Autowired
    ResourceMapper resourceMapper;

    @Override
    public void addResource(ResourceDto resourceDto) {
        Resource resource= new Resource();
        BeanUtils.copyProperties(resourceDto,resource);
        this.getBaseMapper().insert(resource);
    }

    @Override
    public List<ResourceVo> getAllResourceTree() {
        return resourceMapper.getAllResourceTree();
    }
}
